<template>
  <div class="login-container">
    <div class="login-box">
      <h1 class="logo">客户租借登录系统</h1>
      <el-form :model="formInline" class="login-form">
        <el-form-item label="用户名">
          <el-input v-model="formInline.customerPhone" placeholder="请输入用户名"></el-input>
        </el-form-item>

        <el-form-item label="密码">
          <el-input v-model="formInline.password" type="password" placeholder="请输入密码"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="onSubmit" class="login-button">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: "UserView",
  data() {
    return {
      formInline: {
        name: '',
        password: ''
      }
    }
  },
  methods: {
    onSubmit() {
      this.axios.post("/car/login", this.formInline).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.msg);
          sessionStorage.setItem("token", res.data.data.token);
          sessionStorage.setItem("id", res.data.data.id);
          sessionStorage.setItem("name", res.data.data.name);
          this.$router.push("/vehicle");
        } else {
          this.$message.error(res.data.msg);
        }
      })
    }
  }
}
</script>

<style scoped>
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(to right, #6dd5ed, #2193b0);
}

.login-box {
  width: 100%;
  max-width: 400px;
  padding: 20px;
  text-align: center;
}

.logo {
  font-size: 24px;
  color: #fff;
  margin-bottom: 40px;
  font-weight: bold;
}

.login-form {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.el-input__inner {
  border-radius: 4px;
}

.el-button {
  border-radius: 4px;
}

.login-button {
  margin-top: 20px;
  width: 100%;
  background-color: #5469d4;
  border-color: #5469d4;
}

.login-button:hover {
  background-color: #4345ac;
  border-color: #4345ac;
}

.el-form-item__label {
  font-weight: 500;
  color: #333;
}

.el-form-item {
  margin-bottom: 20px;
}
</style>
